import 'package:dk_flutter_base/dk_ui.dart';
import 'package:dk_flutter_module_sale/phoenix/home/bean/home_form_bean.dart';
import 'package:dk_flutter_module_sale/phoenix/home/widget/work_head_widget.dart';
import 'package:flutter/material.dart';
import '../bean/ui_const_bean.dart';
import '../widget/work_warp_widget.dart';
import '../bean/work_home_bean.dart';

class WorkFormWidget extends StatelessWidget {

  final Function(HomeFormBean)           workFormTap;
  final UpdateModuleListBean    updateModuleBean;
  final HomeFormBean            homeFormBean;

  WorkFormWidget(this.updateModuleBean,this.homeFormBean,this.workFormTap);

  @override
  Widget build(BuildContext context) {
    return buildedNewWidget(context);
  }

  Widget buildedNewWidget(BuildContext context) {
    double  height = 0.0;
    height = (homeFormBean == null) ? 220.0 :  homeFormBean.list.length > 3 ? 220 : 148;
    return GestureDetector(
      child: Container(
        height: height,
        color: Colors.transparent,
        padding: const EdgeInsets.only(left: UIConstBean.LRSpace, right: UIConstBean.LRSpace, top: 10),
        child: Card(
          color: Colors.white,
          elevation: 0.0,
          margin: const EdgeInsets.only(bottom: 0),
          clipBehavior: Clip.antiAliasWithSaveLayer,
          shape: const RoundedRectangleBorder(
            side: BorderSide.none,
            borderRadius: BorderRadius.all(Radius.circular(UIConstBean.CircularRadius),
            ),
          ),
          child: Container(
            padding: const EdgeInsets.only(left: UIConstBean.InnerLRSpace,right: UIConstBean.InnerLRSpace,top: UIConstBean.InnerTopSpace),
            color: Colors.white,
            child: Column(
              children: <Widget>[
                WorkHeadWidget(itemHeadTap: null, title: updateModuleBean.title,indicateType: (homeFormBean == null) ?  HomeHeadTitleIndicateType.HomeHeadTitleIndicateDefaultType : HomeHeadTitleIndicateType.HomeHeadTitleIndicateLookAtType,),
                SizedBox(height: 19,),
                Expanded(
                  child: WorkWarpWidget(updateModuleBean,homeFormBean),
                ),
              ],
            )
          ),
        ),
      ),
      onTap: () {
        print('----workFormTap----');
        if(workFormTap!= null) {
          workFormTap(homeFormBean);
        }
      },
    );
  }
}

